import { Component } from 'react'
import Taro from '@tarojs/taro'
import {RichText, Text, OpenData, WebView} from '@tarojs/components'
import './index.scss'
import global from '../../global';
import Request from "../../api";


export default class Index extends Component {

  constructor(props) {
    super(props);
    this.updateRemindStatus = this.updateRemindStatus.bind(this);
  }

  componentWillMount () {
    Taro.setNavigationBarTitle({
      title: global.noticeTextTitle || '通知公告'
    });
    this.updateRemindStatus();
  }
  async updateRemindStatus() {
    try {
      let res = await Request.get(`/business/operation_remind/updateStatus/${global.currentNotice.noticeId}/NOTICE/${global.userInfo.userId}`);
      if (res.data.code !== 200) {
        throw new Error();
      }
      console.log(res.data.data)
    } catch (e) {
      console.log("更新状态异常")
    }
  }
  componentDidMount () {}

  componentWillUnmount () {}

  componentDidShow () {}

  componentDidHide () { }

  render () {
    let noticeText = global.noticeText;
    noticeText = `<div class="ql-editor">${noticeText}</div>`
    return (
      <RichText type='text' nodes={noticeText.replace(/\<img/g, '<img style="max-width:100%;height:auto"')
        .replace(/em;/g,'rpx;')
        .replace(/<section/g, '<div').replace(/\/section>/g, '/div>')
        .replaceAll('/dev-api/', 'http://192.168.1.102:8080/')} >
      </RichText>
    )
  }
}
